﻿namespace YawetagLib.Security
{
    public class RoleBuilder
    {
        public RoleBuilder()
        {
            Roles = string.Empty;
        }

        public RoleBuilder AddRole(bool hasRole, string role)
        {
            if (hasRole)
            {
                Roles += "*" + role;
                if (Roles.StartsWith("*")) { Roles = Roles.Remove(0, 1); }
            }

            return this;
        }

        public RoleBuilder AddRole(string role)
        {
            return AddRole(true, role);
        }

        public override string ToString()
        {
            return Roles;
        }

        private string Roles { get; set; }
    }
}
